package week06.member.personcmp;

public abstract class AbstractPersonCmp {
    protected  abstract int compare(Person p1,Person p2);

    //sort是模板方法
    public void sort(Person[] personArray){
        for(int i=0;i<personArray.length-1;i++){
            for(int j=i+1;i<personArray.length;j++){
                if(compare(personArray[i],personArray[j])<0){
                    Person tmp=personArray[i];
                    personArray[i]=personArray[j];
                    personArray[j]=tmp;
                }
            }
        }

    }
}
